Not ambiguous, but inclusive in meaning
Ambiguity implies two or more possible meanings that are unclear as to which it is, or more broadly simply being unclear. I do not believe that is the situation here at all.
Examining the statements
Let's start with the basically undisputed OT reference Paul is using in Romans.
The (very literal) Hebrew of Habakkuk 2:4 is (read the English "groupings" backwards for each
< since Hebrew is reversed from English):1
הִנֵּ֣ה עֻפְּלָ֔ה לֹא־יָשְׁרָ֥ה נַפְשׁ֖וֹ בּ֑וֹ
in him < his soul < she be not right < she has swollen < behold
וְצַדִּ֖יק בֶּאֱמוּנָת֥וֹ יִחְיֶֽה
he be living < by his faithfulness < but the righteous
MINE: Behold, his soul in him has swollen, [his soul in him] be not right, but the righteous by his faithfulness he be living.
ESV: Behold, his soul is puffed up; it is not upright within him, but the righteous shall live by his faith.
NKJV: Behold the proud, His soul is not upright in him; But the just shall live by his faith.
"she has swollen, she be not right, his soul in him"
Hebrew uses the feminine gender for many things besides simply a reference to an actual female person. One of those things commonly associated to the feminine is abstract concepts,2 and so the idea of the "soul" or "life" of a person is such. So the subject of the two verbs is the "she," the "soul" in the verse. This soul is of the generic "man," it is "his soul in him."
The first verb is a rare verb, having reference to swollen or enlarged things (tumors, or a derivative word for mound/hill, etc.). It is in the pual perfect, the perfect in context referring to a state or condition,3 while the pual is a passive form of the piel, that here is probably resultative.4 This swelling of the soul has resulted in a state of "being not right."
"but the righteous by his faithfulness he be living"
The וְ (waw) here prefixed is often translated "and," but the context here of the contrast is why it is translated "but." So the phrase in question for you is in contrast with the preceding. This one who is not right because of a swelled up soul is contrasted to one who is simply stated as already being "righteous," and of this one, "by/in/with/through his faithfulness," there is a relationship to the fact that "he shall be living" (a qal imperfect, giving the idea of an incomplete event at present and/or future).5
The preposition בֶּ (b) can have the same flexibility as English or Greek.
So what is Habakkuk saying? (And thus Paul later.)
Habakkuk is lamenting the success of the wicked in Israel, who even "surround the righteous" (NKJV, v.4; all quotes from NKJV), and he is questioning God's actions of not judging them (1:1-4). God replies for Habakkuk to wait, the Chaldeans (Babylonians) are being prepared to come and bring swift judgment (1:5-11; referring to the coming destruction of Jerusalem and Babylonian captivity).
In reply, Habakkuk knows and trusts his Holy God, and affirms "we shall not die" (1:12), but questions (1:12-17) why God would suffer the wicked Chaldeans to "continue to slay nations without pity" (v.17). But Habakkuk knows to question his God so, he will be corrected in his misunderstandings (2:1).
God replies to "write the vision ... for an appointed time," because it is not yet, but "will surely come" (2:2-3).
Enter v.4, the verse in question. It is a summary answer of God to Habakkuk. It is stating a general truth that basically is this:
(1) The proud are not righteous in their soul
(2) Those righteous in their soul (not proud, and thus humble, and thus faithful)
(3) by means of having faith (i.e. faithfulness) shall live
In the context of the judgement passage, it is a reference to the righteous one avoiding judgment that is bringing an impending death by being faithful. Thus the imperfect here is a future idea of preservation of life.
God continues in describing the proud and all the ways they lift themselves by their sin (2:5-19). In this passage specifically, however, it states "the glory of the LORD" is coming (v.14), and the "cup of the LORD's right hand will be turned against you" (v.16), which without going into detail means his judgment. This will defeat the glory of the proud (v.16). Indeed, there is none in "all the earth" that can speak against His ways (v.20).
Notice how the context is the same as Habakkuk. Paul is speaking of the faithful (1:7-16), in contrast to the wicked who are impending judgment (1:18-32; and even following that).
The verse is often considered the key verse to the book of Romans, because the book organizes around expanding upon that statement. This is not the place to expand the discussion fully to that level, but some expansion needs to be done.
So the translation of the Greek is best as you give above by the ESV, NIV, KJV, "the just/righteous shall live by faith" or more literally, "the just by faith shall live." It is stating that one will "live" (future, as ζήσεται is explicitly future tense in the Greek, unlike the Hebrew imperfect which has a broader range of meaning) if one is faithful (has faith), which only the righteous evidences.
This idea that to live one must have faith and be righteous is what Paul is expanding upon from the OT. One is only considered righteous by having faith, (Gen 15:6; Rom ch. 4) and faith is only in the humble (for the proud trust in themselves, not God). There is none righteous of themselves (Job 9:2-3; Ps 14:1-3, 53:1-3, 143:2; Eccl 7:20; Rom 3:10-18), so all under wrath and are deserving of death (Hab 2:16; Rom 1:18, 32).
But God does in fact "in wrath remember mercy" as Habakkuk prayed (3:2), for those of the wicked who humble themselves before God (i.e. have faith), righteousness itself is accounted, and thus the righteousness that comes by faith (which is what qualifies one to be called "righteous" in God's sight), by that same faith is what brings life to that righteous one, of which Paul is speaking of eternal life (Rom ch. 5).
This faith that brings life will also be lived out in one's life--thus my title to this answer, "by means of faith he shall be living" is inclusive in meaning that (1) the righteous person will continue in the future to evidence faith, as that is a quality only the righteous have, and (2) the righteous person will find eternal life, free from future judgment, by means of that faith that accounted them righteous to begin with.
So Rom 1:17 is not itself ascribing righteousness by faith, that is found in the other OT and NT passages that do explicitly teach how one is accounted righteous.
Rather, Rom 1:17 is assuming that one is already righteous by that means, and by that same faith, that one will live through God's wrath, the second death that is coming, because they are not trusting in their own prideful, unrighteous works which do lead to death (Isa 64:6; Rom 4:3-5; Gal 2:16; Rev 20:12-15).
If I get time (I've spent a number of hours on this already), I'll dig up some historical info.
1 Word definitions for translation come from the appropriate words referenced in either/both of (1) Francis Brown, Samuel Rolles Driver, and Charles Augustus Briggs, Enhanced Brown-Driver-Briggs Hebrew and English Lexicon (Oak Harbor, WA: Logos Research Systems, 2000), hereafter BDB; (2) Ludwig Koehler, Walter Baumgartner, M. E. J. Richardson, and Johann Jakob Stamm The Hebrew and Aramaic Lexicon of the Old Testament (Leiden; New York: E.J. Brill, 1999), hereafter HALOT.
2 Christo Van der Merwe, Jackie Naudé, and Jan Kroeze A Biblical Hebrew Reference Grammar, (Sheffield: Sheffield Academic Press, 1999), §18.104.22.168.a; hereafter BHRG.
3 BHRG, §19.2.2.
4 BHRG, §22.214.171.124 and §126.96.36.199; it probably has repetitive or intensifying idea as well. See Friedrich Wilhelm Gesenius, Gesenius’ Hebrew Grammar, edited by E. Kautzsch and Sir Arthur Ernest Cowley, 2d English ed. (Oxford: Clarendon Press, 1910).
5 BHRG, §15.2.